package wusiyuan.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import entity.User_Address;
import wusiyuan.service.AddTheAddressService;
import wusiyuan.service.impl.AddTheAddressServiceImpl;




public class AddTheAddressServlet extends HttpServlet {
	
	private AddTheAddressService aas = new AddTheAddressServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Integer province = Integer.parseInt(request.getParameter("province"));
		Integer city = Integer.parseInt(request.getParameter("city"));
		Integer county = Integer.parseInt(request.getParameter("county"));
		String consignee = request.getParameter("consignee");
		String zip_code = request.getParameter("zip_code");
		String address = request.getParameter("address");
		String sex = request.getParameter("sex");
		String phone = request.getParameter("phone");
		String remark = request.getParameter("remark");
		System.out.println(province + "     " + city + "       " + county);
		System.out.println(consignee + "\t" + zip_code + "\t" + address + "\t" + sex + "\t" + phone + "\t" + remark);
		User_Address ua = new User_Address();
		ua.setConsignee(consignee);
		ua.setPhone(phone);
		ua.setZip_code(zip_code);
		ua.setSex(sex);
		ua.setAddress(address);
		ua.setRemark(remark);
		ua.setUserId(1);
		ua.setProvince(province);
		ua.setCity(city);
		ua.setDistrict(county);
		ua.setIs_default(6);
		ua.setModified_time(null);
		Integer i = aas.addAddress(ua);
		System.out.println(i);
		response.getWriter().print(i);
		HttpSession session = request.getSession(); 
		session.setAttribute("User_Address" ,ua);		
		
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		doGet(request, response);
	}

}
